home *** CD-ROM | disk | FTP | other *** search
- TITLE MULBUG - COMPAQ Computer Corporation/Microsoft Corp.
- ;******************************************************************************
- ;
- ; Title: MULBUG - 80386 32-bit MULtiply test subroutine
- ;
- ; Module: MULBUG
- ;
- ; Version: *
- ;
- ; Date: April 11, 1987
- ;
- ; This subroutine provides a quick indication of the function of the
- ; 32-bit MUL instruction in the Intel 80386.
- ;
- ; This subroutine and its source code may be freely used and copied.
- ;
- ;******************************************************************************
-
-
- PASS EQU 0 ; exit codes (arbitrary values)
- FAIL EQU 1
-
- OP32 MACRO
- DB 66h ; 32-bit operand override prefix
- ENDM
-
- ; Static Name Aliases
- ;
-
- .287
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- _TEXT ENDS
- _DATA SEGMENT WORD PUBLIC 'DATA'
- _DATA ENDS
- CONST SEGMENT WORD PUBLIC 'CONST'
- CONST ENDS
- _BSS SEGMENT WORD PUBLIC 'BSS'
- _BSS ENDS
-
- DGROUP GROUP CONST, _BSS, _DATA
- ASSUME CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
-
- ;------------------------------------------------------------------------------
- ; Patterns for 32-bit multiply test
- ;
- _DATA SEGMENT
- multiplier DD 00000081h ; multiplier
- multiplicand DD 0417A000h ; multiplicand
- goodhi DD 00000002h ; correct product (high order)
- goodlo DD 0FE7A000h ; correct product (low order)
- _DATA ENDS ; end of segment
-
- _TEXT SEGMENT
- ;------------------------------------------------------------------------------
- ; MULTEST - Check the 386 32-bit multiply instruction.
- ;
- ; ENTRY: (none) - C callable
- ; EXIT: AX = PASS, FAIL
- ; USED:
- ; STACK:
- ;
- _multest PROC NEAR
- PUBLIC _multest
- push bp
- mov bp,sp
- mov cx,0000 ; 64K times is a nice round number
- mt_loop:
- call _mulproc ; check the chip function
- cmp ax,FAIL ; Q: did it work ?
- je mt_exit ; N: display message and exit
- loop mt_loop ; Y: PASSED, loop to try again
- mt_exit:
- mov sp,bp
- pop bp
- ret
- _multest ENDP
-
- ;------------------------------------------------------------------------------
- ; mulproc - 32-bit multiply pattern test. The supplied pattern
- ; values must be used for consistent results.
- ;
- ; ENTRY: (none) - C callable
- ; EXIT: EAX = PASS, FAIL
- ; USED: EAX, EBX, EDX
- ; STACK: 2 bytes
- ;
- _mulproc PROC NEAR
- PUBLIC _mulproc
- OP32
- mov bx,word ptr [multiplier]
- ; mov ebx,[multiplier]
- OP32
- mov ax,word ptr [multiplicand]
- ; mov eax,[multiplicand]
- OP32
- mul bx ; mul ebx
-
- OP32 ; Q: high order answer OK ?
- cmp dx,word ptr [goodhi] ; cmp edx,[goodhi]
- jne mp_fail ; N: exit with error
- OP32 ; Q: low order answer OK ?
- cmp ax,word ptr [goodlo] ; cmp eax,[goodlo]
- je mp_pass ; Y: good answer, exit...
- ; N: exit with error
- mp_fail:
- mov ax,FAIL ; set 'fail' return code
- jmp short mp_exit ; and exit
-
- mp_pass:
- mov ax,PASS ; set 'pass' return code
- ;; jmp short mp_exit ; and exit
-
- mp_exit:
- ret ; *** RETURN ***
- _mulproc ENDP
- _TEXT ENDS
-
- END
-